package com.lluohao.service.impl;

import com.lluohao.common.ChatMessageHandler;
import com.lluohao.common.ListMessageHandler;
import com.lluohao.common.RecordMessageHandler;
import com.lluohao.service.IMessageService;
import com.lluohao.web.controller.MessageVO;
import com.lluohao.web.controller.Result;

/**
 * Created by Everthing-- on 2017/7/5.
 */
public class MessageServiceImpl implements IMessageService{
    private ListMessageHandler handler;
    public MessageServiceImpl(){
        handler = new ListMessageHandler();
        handler.addHandler(new RecordMessageHandler());
        ChatMessageHandler chatMessageHandler = new ChatMessageHandler();
        handler.addHandler(chatMessageHandler);
    }
    public String handler(MessageVO message) {
        Result result = handler.handler(message);
        if(result!=null&&result.getCode()==200){
            return result.toString();
        }
        return "";
    }
}
